package com.elitesland.system.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Version;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * <pre>取号下一编号</pre>
 *
 * @author mir
 * @date 2020-10-10
 **/

@Entity
@Table(name = "sys_next_number")
@org.hibernate.annotations.Table(appliesTo = "sys_next_number", comment = "取号下一编号表")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "取号下一编号表", description = "取号下一编号表")
public class SysNextNumberDO extends BaseModel implements Serializable {
    private static final long serialVersionUID = 8103746715455248936L;

    @ApiModelProperty(value = "下一编号代码")
    @Comment("下一编号代码")
    @Column(nullable = false, unique = true)
    String code;

    @ApiModelProperty(value = "下一编号名称")
    @Comment("下一编号名称")
    @Column(nullable = false)
    String name;

    @ApiModelProperty(value = "下一编号分类")
    @Comment("下一编号分类")
    @Column()
    String numberClass;

    @ApiModelProperty(value = "下一编号步长")
    @Comment("下一编号步长")
    @Column()
    Integer step;

    @ApiModelProperty(value = "下一编号取值")
    @Comment("下一编号取值")
    @Column()
    Long nextNumber;

    @ApiModelProperty(value = "下一编号周期[UDC]SYS:NNPERIOD")
    @Comment("下一编号周期")
    @Column()
    String nnPeriod;

    @ApiModelProperty(value = "发号时间")
    @Comment("发号时间")
    @Column()
    LocalDateTime nnTime;

    @ApiModelProperty("乐观锁标记")
    @Comment("乐观锁标记")
    @Column
    @Version
    Integer version;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SysNextNumberDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SysNextNumberDO entity = (SysNextNumberDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}